
<template>

  <el-container style=" border: 1px solid #eee">
    <leftside> </leftside>
  <el-container style="clear:both;width:100%" >
    <div style="width:100%;height:700px;clear:both;overflow:auto">
      <h1 >核销记录查询（bduid查询）</h1>  
      <el-input v-model="input" placeholder="请输入bduid"></el-input>
      <el-button v-on:click="getmsg">查询</el-button>
          <el-table :data="tableData" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="tpcode" label="tp识别码" style="width:10%">
                </el-table-column>
                <el-table-column prop="tpname" label="tp名称" style="width:10%">
                </el-table-column>
                <el-table-column prop="bduid" label="百度uid" style="width:10%">
                </el-table-column>
                <el-table-column prop="mobile" label="手机号" style="width:10%">
                </el-table-column>
                <el-table-column prop="c_time" label="获取时间"  style="width:200px">
                </el-table-column>
                <el-table-column prop="m_time" label="修改时间（核销时间)" style="width:200px">
                </el-table-column>
                <el-table-column prop="isused" label="是否使用" style="width:10%">
                </el-table-column>
                <el-table-column prop="good_id" label="商品id" style="width:10%">
                </el-table-column>
            </el-table>
    </div>
            
  </el-container>
</el-container>

</template>

<style>
    .el-table .warning-row {
        background: oldlace;
    }

    .el-table .success-row {
        background: #f0f9eb;
    }
</style>
<script>
import {config} from '../util'
import axios from 'axios'
import fetchJsonp from 'fetch-jsonp';
import leftside from './layout/leftside';

  export default {
    components: {
     leftside
    },
   
    data() {
     return {
                judgearr:[],
                input:'',
                visible: false,
                tableData: []
            }
    },
    

    methods:{
            tableRowClassName({row, rowIndex}) {
                var $this=this
                var confarr= $this.judgearr
                console.log(row)
                console.log(rowIndex)
//                if (confarr.indexOf(rowIndex)!=-1) {
//                    return 'warning-row';
//                } else {
//                    return 'success-row';
//                }
                if (row.isused=="未使用") {
                    return 'warning-row';
                } else {
                    return 'success-row';
                }
                return '';
            },
            getmsg:function(){
                var $this=this
                var bduid=this.input
                if(bduid==''){
                    alert('请输入要查询的mobile')
                    return
                }
                var requerturl="http://10.99.110.223:8889/getmsgbybduid.php?jsonp=1&bduid="+bduid
                fetchJsonp(requerturl)
                .then(function(response) {
                  return response.json()
                }).then(function(json) {
                  // var json=JSON.parse(json)
                        $this.tableData=[]
                        for(var i=0;i<json.length;i++){
                            $this.judge=[]
                            if(json[i].isused=='0'){
                                json[i].isused="未使用"
                                $this.judgearr.push(i)
                            }else{
                                json[i].isused="已经使用"
                            }
                            $this.tableData.push(json[i])
                            
                        }
                        $this.tableRowClassName
                }).catch(function(ex) {
                  console.log('parsing failed', ex)
                  $this.fullscreenLoading = false;

                })
                      
            }
        }
  };
</script>
<style>
.block{
  margin:15px;
}

</style>


           